package com.songlanyun.common.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 分销枚举
 */
public class DistributionConstant {

    /**
     * 0\一二级分佣、1\282分佣、2\6750礼包分佣、3\差价分佣、4\分享分佣\ 5礼包之非创客礼包分润
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum DistributionComputer implements IntegerEnum<Integer> {

        COMMON(0, "直推分润"),
        DIRECT_GROUP_LEADER(1, "团队分润"),
        INDIRECT_GROUP_LEADER(2,"平级分润"),
        AREA_AGENT(3,"线上订单属地分润"),

        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        DistributionComputer(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static DistributionConstant.DistributionComputer getByCode(int code) {
            for (DistributionConstant.DistributionComputer value : DistributionConstant.DistributionComputer.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 0,自营商品1级分佣，
     * <p>
     * 1,自营商品2级分佣，
     * <p>
     * 2,代销商品小程序分佣282,1级分佣
     * <p>
     * 3,代销商品小程序分佣282,2级分佣
     * <p>
     * 4,代销商品小程序分佣282最近的市代分佣
     * <p>
     * 5,代销商品小程序分佣6750，直接上级平台合伙人分佣
     * 6,代销商品小程序分佣6750，间接上级县级代理或市级代理分佣
     * 7,代销商品小程序分佣6750，直接上级县级代理或市级代理分佣
     * 8,代销商品小程序分佣6750，县级代理或市级代理10%分佣
     * 9,代销商品小程序分佣6750，县级代理或市级代理7%分佣
     * <p>
     * 10,代销商品小程序差价分佣，直接平台合伙人差价分佣
     * 11,代销商品小程序差价分佣，间接上级县级代理或市级代理差价分佣
     * 12,代销商品小程序差价分佣，直接上级县级代理或市级代理差价分佣
     * 13,代销商品小程序差价分佣，县级代理或市级代理10%分佣
     * 14,代销商品小程序差价分佣，县级代理或市级代理7%分佣
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum DistributionType implements IntegerEnum<Integer> {

        COMMON_ONE_LEVEL(0, "直接1级分润"),
        COMMON_TWO_LEVEL(1, "间接2级分润"),
        DIRECT_GROUP_LEADER(2, "直接团长分润"),
        INDIRECT_GROUP_LEADER(3,"间接团长分润"),
        AREA_AGENT(4,"线上订单属地分润"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        DistributionType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static DistributionConstant.DistributionType getByCode(int code) {
            for (DistributionConstant.DistributionType value : DistributionConstant.DistributionType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }



}
